package main

import (
	"fmt"
	"gorule/core"
)

func main(){
	ctx := core.NewContext()
	ctx.Set("bool", false)
	rule1 := core.RegexRule(
		[]string{},
		func(self *core.RegexRuleStruct, ctx *core.Context) bool {
			return false
		},
		func(self *core.RegexRuleStruct, ctx *core.Context) {
		},
	)
	rule2 := core.RegexRule(
		[]string{},
		func(self *core.RegexRuleStruct, ctx *core.Context) bool {
			return true
		},
		func(self *core.RegexRuleStruct, ctx *core.Context) {
		},
	)
	fmt.Println("rule1", rule1.Condition(&ctx))
	fmt.Println("rule2", rule2.Condition(&ctx))

	ctx = core.NewContext()
	rule3 := core.AndRuleStruct{}
	rule3.AddRule(rule1, rule2)
	rule3.Execute(&ctx)
	fmt.Println("rule3", rule3.Condition(&ctx))

	ctx = core.NewContext()
	rule4 := core.OrRule(core.RegexRule(
		[]string{},
		func(self *core.RegexRuleStruct, ctx *core.Context) bool {
			return false
		},
		func(self *core.RegexRuleStruct, ctx *core.Context) {
		},
	), rule2)
	fmt.Println("rule4", rule4.Condition(&ctx))
}